# -*- coding:utf-8 -*-
"""
作者：Admin
日期：2023年12月14日
"""
from PIL import Image
import numpy as np
from keras.src.saving.legacy.save import load_model

# 打开图片
image = Image.open('5.png')

# 转为灰度图
gray_image = image.convert('L')

# 设置图片尺寸为28px
gray_image = gray_image.resize((28, 28))

# 保存图片
gray_image.save('gray_5.jpg')

normalized_image = np.asarray(gray_image)/255
print(normalized_image)
normalized_image = normalized_image.reshape(1,784)
model = load_model('model.h5')
y_pred=model.predict(normalized_image)
print(np.argmax(y_pred, axis=1)[0])
